package zutils

import (
	"bytes"
	"encoding/binary"
)

func IntToBytes(n int) []byte {
	x := int64(n)
	byteBuffer := bytes.NewBuffer([]byte{})
	binary.Write(byteBuffer, binary.BigEndian, x)
	return byteBuffer.Bytes()
}

func BytesToInt(b []byte) int {
	byteBuffer := bytes.NewBuffer(b)
	var x int64
	binary.Read(byteBuffer, binary.BigEndian, &x)
	return int(x)
}
